<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>
<style type="text/css">
#processImageDiv div.flowNode {
	cursor: pointer;
}
</style>
<form:form commandName="model" cssClass="validate"
	id="processSettingForm" action="bpm/processSetting/save">
	<form:hidden path="id" />
	<table class=" form-table">
		<tbody>

			<tr>
				<td class="td1">实体：</td>
				<td class="td2"><form:hidden path="dbEntityId" /> <isperp:listSelector
						displayValue="${dbEntityName}" valueControlId="dbEntityId"
						id="lsDbEntity" url="db/entity/list">
						<isperp:column name="id" title="id" hidden="true"></isperp:column>
						<isperp:column name="entityCategory" title="分类" width="120">
						</isperp:column>
						<isperp:column name="name" title="名称" width="170">
						</isperp:column>
						<isperp:column name="entityType" title="实体类型" width="100">
						</isperp:column>
						<isperp:column name="tableName" title="数据表名称" width="120">
						</isperp:column>
						<isperp:column name="useForImport" title="导入" width="70"
							formatter="checkbox">
						</isperp:column>
						<isperp:column name="useForSlm" title="slm计算" width="70"
							formatter="checkbox">
						</isperp:column>
					</isperp:listSelector>
				</td>
			</tr>
			<tr>
				<td class="td1">Slm实体：</td>
				<td class="td2"><form:hidden path="dbForSlmEntityId" /> <isperp:listSelector
						displayValue="${dbForSlmEntityName}"
						valueControlId="dbForSlmEntityId" id="lsDbForSlmEntity"
						url="db/entity/list">
						<isperp:column name="id" title="id" hidden="true"></isperp:column>
						<isperp:column name="entityCategory" title="分类" width="120">
						</isperp:column>
						<isperp:column name="name" title="名称" width="170">
						</isperp:column>
						<isperp:column name="entityType" title="实体类型" width="100">
						</isperp:column>
						<isperp:column name="tableName" title="数据表名称" width="120">
						</isperp:column>
						<isperp:column name="useForImport" title="导入" width="70"
							formatter="checkbox">
						</isperp:column>
						<isperp:column name="useForSlm" title="slm计算" width="70"
							formatter="checkbox">
						</isperp:column>
					</isperp:listSelector>
				</td>
			</tr>
			<tr>
				<td class="td1">流程：</td>
				<td class="td2"><form:hidden path="actReProcdefKey" /> <isperp:listSelector
						displayValue="${model.actReProcdefKey}" valueColumn="key"
						showPager="false" displayColumn="key"
						valueControlId="actReProcdefKey" id="lsProcessDefinitionKey"
						url="workflow/processDefinition/list">
						<isperp:column name="id" title="id" hidden="true"></isperp:column>
						<isperp:column name="key" title="编码" width="100">
						</isperp:column>
						<isperp:column name="name" title="名称" width="150">
						</isperp:column>
						<isperp:column name="version" title="版本" width="50">
						</isperp:column>
						<isperp:column name="createTime" title="创建时间" width="80">
						</isperp:column>
						<isperp:column name="lastUpdateTime" title="更新时间" width="80">
						</isperp:column>
					</isperp:listSelector>
				</td>
			</tr>
			<tr>
				<td class="td1">关联分类：</td>
				<td class="td2"><form:hidden
				path="categoryId" />  <isperp:treeSelector
						width="500" displayColumn="name"
						displayValueCssStyle="width:249px" url="individuation/category/getTree?showMainForm=true"
						autocompleteUrl="individuation/category/list"
					     id="icdCategorySelector"
						name="categoryName" displayValue="${model.categoryName }"
						valueControlId="categoryId" displayValueCssClass=""></isperp:treeSelector>
				</td>
			</tr>
			<tr>
				<td class="td1">起始表单：</td>
				<td class="td2"><form:input path="formStartUrl"
						cssStyle="width:85%" cssClass="required" /></td>
			</tr>
			<tr>
				<td class="td1">查看表单：</td>
				<td class="td2"><form:input path="viewUrl" cssStyle="width:85%"
						cssClass="required" />
				</td>
			</tr>
		</tbody>
	</table>
</form:form>
<div
	style="float:right;right: 20px;margin-top:10px;position: absolute;z-index: 2">
	<a class="nui-txt-link"
		href="javascript:isperp.openDialog({title:'流程设计器',contentUrl:'workflow/modeler.jsp?modelId=${modelId}',onThisWindow:true,maximize:true});">重新设计流程图</a>
	<a class="nui-txt-link" href="javascript:deployProcess('${modelId}');">重新部署流程</a>
</div>

<div id="processImageDiv"
	style="position: relative;background:url('workflow/processDefinition/processImage/${processDefinition.id }')  no-repeat;width:${shapeMeta.width}px;height:${shapeMeta.height}px;">
	${shapeMeta.xml}</div>
<isperp:buttonList>
	<button class="submit" type="button"
		onclick="isperp.submitForm();return false;">保存</button>
</isperp:buttonList>
<script type="text/javascript">
	$("#processImageDiv div.flowNode").click(function() {
		var $e = $(this);
		var type = $e.attr("type");
		var nodeId = $e.prop("id");
		var name = $e.prop("title");
		var processDefinitionId = "${processDefinition.id }";

		var url = "bpm/nodeSetting/edit?bpmProcessSettingId=" + $("#id").val() + "&nodeId=" + nodeId + "&name=" + name + "&type=" + type + "&processDefinitionId=" + processDefinitionId;

		isperp.openDialog({
			title : name + "-设置",
			contentUrl : url
		});

	});

	function deployProcess(modelId) {
		if (!modelId) {
			isperp.alert("请选择一条记录！");
			return false;
		}

		isperp.confirmAlert("重新部署可能会导致现有的任务无法执行，您确定要重新部署吗?", {
			yes : function() {
				isperp.showOverlay();
				$.get("workflow/bpmnModel/deploy", {
					modelId : modelId
				}, function(data) {

					if (data && data.success == false) {
						isperp.warnAlert(data.data);
					} else {
						isperp.tooltip("流程部署成功！");
						window.location.reload();
					}
				});
			}

		});

	}
</script>



